<template>
    <div id="app" style="height: 100%">
        <div style="width: 300px;margin: 0 auto;padding-top: 200px">

            <a-form-model layout="horizontal" :model="formInline" @submit="handleSubmit" @submit.native.prevent>
                <a-form-model-item>
                    <a-input v-model="formInline.name" placeholder="Username">
                        <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)"/>
                    </a-input>
                </a-form-model-item>
                <a-form-model-item>
                    <a-input v-model="formInline.password" type="password" placeholder="Password">
                        <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)"/>
                    </a-input>
                </a-form-model-item>
                <a-form-model-item>
                    <a-button
                            type="primary"
                            html-type="submit"
                            :disabled="formInline.name === '' || formInline.password === ''"
                    >
                        Log in
                    </a-button>
                </a-form-model-item>
            </a-form-model>
        </div>

    </div>
</template>

<script>

    export default {
        name: 'App',
        data() {
            return {
                formInline: {
                    name: 'admin',
                    password: 'admin',
                },
            };
        },
        methods: {
            handleSubmit() {
                console.log(this.formInline);
                this.$axios.post("/sys/user/login", this.formInline).then(res => {
                    console.log(res);
                    if (res.data.status == 200) {
                        this.$message.success("登陆成功");
                        if(this.$env=="development"){
                            window.location.href="http://127.0.0.1:8080/"
                        }else{
                            window.location.href="/"
                        }
                    }else{
                        this.$message.error(res.data.msg);
                    }
                })
            },
        }
    }
</script>

<style>
    #app {

    }
</style>
